FortiGate 50E をUARTブートする
FortiGate 50EのU-Bootはメーカーでカスタマイズされてるようなので、バニラなU-Bootをいれたい
しかし、いれる作業に失敗したら二度と起動できなくなりそう
ストックファームウェアのU-Bootをぶっこわした場合のリカバリ方法を確立しておきたい
Armada 385 のブートROMはUARTブートができるらしいので、FortiGate 50Eで利用可能か試してみることにした
進捗: initramfsが起動できるところまでできた
FortiGate 50E をUARTブートする#66ea4e0195941c0000f85a8a
UARTブートの方法
UARTブートするには、U-Bootに付属しているkwbootというツールを使うらしい
88F6820への言及はある
https://github.com/u-boot/u-boot/blob/c97ada2dc66934ee00a7a03d9ed078bdfb7b4039/tools/kwboot.c#L44
u-bootをビルドする
code:sh
sudo apt-get install gcc-arm-linux-gnueabihf
git clone https://github.com/u-boot/u-boot.git
cd u-boot
git checkout -b v2024.07 refs/tags/v2024.07
make db-88f6820-amc_defconfig
make CROSS_COMPILE=arm-linux-gnueabihf-
u-boot-with-spl.kwb ができてれば成功✌
db-88f6820-amc_defconfig であってるのかわからないけどとりあえずこれで
88F6820に関連してそうなdefconfigは以下のものがあった
code:sh
$ ls -1 configs | grep 88f6820
db-88f6820-amc_defconfig
db-88f6820-amc_nand_defconfig
db-88f6820-gp_defconfig
kwbootのインストール
code:sh
sudo apt install u-boot-tools
UARTブートの実行
FortiGate E50 の電源を抜く
シリアルコンソールケーブルを接続する
以下のコマンドを実行する
code:sh
sudo kwboot -b u-boot-with-spl.kwb -t -B 115200 /dev/ttyUSB0
FortiGate E50 の電源を接続する
実行結果
メッセージ的に、U-Boot SPL までは起動できているっぽい?
code:txt
$ sudo kwboot -b u-boot-with-spl.kwb -t -B 115200 /dev/ttyUSB0
kwboot version 2023.01
Patching image boot signature to UART
Aligning image header to Xmodem block size
Sending boot message. Please reboot the target...\
Sending boot image header (140032 bytes)...
0 % ......................................................................
6 % ......................................................................
12 % ......................................................................
19 % ......................................................................
25 % ......................................................................
32 % ......................................................................
38 % ......................................................................
44 % ......................................................................
51 % ......................................................................
57 % ......................................................................
64 % ......................................................................
70 % ......................................................................
76 % ......................................................................
83 % ......................................................................
89 % ......................................................................
96 %
Done
U-Boot SPL 2024.07 (Sep 18 2024 - 04:01:32 +0900)
High speed PHY - Version: 2.0
Detected Device ID 6820
board SerDes lanes topology details:
| Lane # | Speed | Type |
--------------------------------
| 0 | 5 | PCIe0 |
| 4 | 0 | SGMII1 |
| 5 | 0 | SGMII2 |
--------------------------------
High speed PHY - Ended Successfully
mv_ddr: 14.0.0
2回目以降、DRAM initialization Failed (res 0x1) と出てくる
code:txt
$ sudo kwboot -b u-boot-with-spl.kwb -t -B 115200 /dev/ttyUSB0
kwboot version 2023.01
Patching image boot signature to UART
Aligning image header to Xmodem block size
Sending boot message. Please reboot the target...-
Sending boot image header (140032 bytes)...
0 % ......................................................................
6 % ......................................................................
12 % ......................................................................
19 % ......................................................................
25 % ......................................................................
32 % ......................................................................
38 % ......................................................................
44 % ......................................................................
51 % ......................................................................
57 % ......................................................................
64 % ......................................................................
70 % ......................................................................
76 % ......................................................................
83 % ......................................................................
89 % ......................................................................
96 %
Done
U-Boot SPL 2024.07 (Sep 18 2024 - 04:01:32 +0900)
High speed PHY - Version: 2.0
Detected Device ID 6820
board SerDes lanes topology details:
| Lane # | Speed | Type |
--------------------------------
| 0 | 5 | PCIe0 |
| 4 | 0 | SGMII1 |
| 5 | 0 | SGMII2 |
--------------------------------
High speed PHY - Ended Successfully
mv_ddr: 14.0.0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
PBS failed for IF #0
ddr3_tip_pbs_rx failure CS #0
Title: I/F# , Tj, Calibration_n0, Calibration_p0, Calibration_n1, Calibration_p1, Calibration_n2, Calibration_p2,CS0 ,
VWTx, VWRx, WL_tot, WL_ADLL, WL_PH, RL_Tot, RL_ADLL, RL_PH, RL_Smp, Cen_tx, Cen_rx, Vref, DQVref, PBSTx-Pad0,PBSTx-Pad1,PBSTx-Pad2,PBSTx-Pad3,PBSTx-Pad4,PBSTx-Pad5,PBSTx-Pad6,PBSTx-Pad7,PBSTx-Pad8,PBSTx-Pad9,PBSTx-Pad10, PBSRx-Pad0,PBSRx-Pad1,PBSRx-Pad2,PBSRx-Pad3,PBSRx-Pad4,PBSRx-Pad5,PBSRx-Pad6,PBSRx-Pad7,PBSRx-Pad8,PBSRx-Pad9,PBSRx-Pad10,
Data: 0,47,15,13,15,13,20,20,CS0 ,
0,0,81,17,2,575,31,5,6,30,10,4,0, 0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,
0,0,74,10,2,575,31,5,6,23,10,4,0, 0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,
0,0,72,8,2,575,31,5,6,21,10,4,0, 0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,
0,0,84,20,2,575,31,5,6,33,10,4,0, 0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,
******** DRAM initialization Failed (res 0x1) ********
DDR3 Training Sequence - FAILED
ddr3_init() failed: 1
### ERROR ### Please RESET the board ###
xmodem: Connection timed out
db-88f6820-gp_defconfig のほうを試してみる
db-88f6820-amcはAMC規格というのに準拠してるもので、普通のボードだとdb-88f6820-gpが使われるらしい
https://www.perplexity.ai/search/db-88f6820-gp-to-db-88f6820-am-nm.kwX4jQsqvBUb5znTuGw#0
ビルド
code:sh
make db-88f6820-gp_defconfig
make CROSS_COMPILE=arm-linux-gnueabihf-
起動
こんどはSPLだけでなくU-Bootの起動にも成功したっぽい
なので結論としては db-88f6820-gp_defconfig が正解
code:txt
$ sudo kwboot -b u-boot-with-spl.kwb -t -B 115200 /dev/ttyUSB0
kwboot version 2023.01
Patching image boot signature to UART
Aligning image header to Xmodem block size
Sending boot message. Please reboot the target...\
Sending boot image header (131840 bytes)...
0 % ......................................................................
6 % ......................................................................
13 % ......................................................................
20 % ......................................................................
27 % ......................................................................
34 % ......................................................................
40 % ......................................................................
47 % ......................................................................
54 % ......................................................................
61 % ......................................................................
68 % ......................................................................
74 % ......................................................................
81 % ......................................................................
88 % ......................................................................
95 %
Done
U-Boot SPL 2024.07 (Sep 18 2024 - 04:41:30 +0900)
High speed PHY - Version: 2.0
Detected Device ID 6820
board SerDes lanes topology details:
| Lane # | Speed | Type |
--------------------------------
| 0 | 5 | PCIe0 |
| 1 | 3 | SATA0 |
| 2 | 3 | SATA1 |
| 3 | 3 | SATA3 |
| 4 | 3 | SATA2 |
| 5 | 5 | USB3 HOST1 |
--------------------------------
hws_serdes_topology_verify: Warning: serdes lane 3 is set to type SATA3.
hws_serdes_topology_verify: Maximum supported lanes are already set to this type (limit = 2)
hws_update_serdes_phy_selectors: SerDes lane #3 is disabled
hws_serdes_topology_verify: Warning: serdes lane 4 is set to type SATA2.
hws_serdes_topology_verify: Maximum supported lanes are already set to this type (limit = 2)
hws_update_serdes_phy_selectors: SerDes lane #4 is disabled
board SerDes lanes topology details:
| Lane # | Speed | Type |
--------------------------------
| 0 | 5 | PCIe0 |
| 1 | 3 | SATA0 |
| 2 | 3 | SATA1 |
| 5 | 5 | USB3 HOST1 |
--------------------------------
High speed PHY - Ended Successfully
mv_ddr: 14.0.0
DDR3 Training Sequence - Switching XBAR Window to FastPath Window
mv_ddr: completed successfully
Trying to boot from BOOTROM
Returning to BootROM (return address 0xffff05c4)...
Sending boot image data (567736 bytes)...
0 % ......................................................................
1 % ......................................................................
3 % ......................................................................
4 % ......................................................................
6 % ......................................................................
7 % ......................................................................
9 % ......................................................................
11 % ......................................................................
12 % ......................................................................
14 % ......................................................................
15 % ......................................................................
17 % ......................................................................
18 % ......................................................................
20 % ......................................................................
22 % ......................................................................
23 % ......................................................................
25 % ......................................................................
26 % ......................................................................
28 % ......................................................................
30 % ......................................................................
31 % ......................................................................
33 % ......................................................................
34 % ......................................................................
36 % ......................................................................
37 % ......................................................................
39 % ......................................................................
41 % ......................................................................
42 % ......................................................................
44 % ......................................................................
45 % ......................................................................
47 % ......................................................................
48 % ......................................................................
50 % ......................................................................
52 % ......................................................................
53 % ......................................................................
55 % ......................................................................
56 % ......................................................................
58 % ......................................................................
59 % ......................................................................
61 % ......................................................................
63 % ......................................................................
64 % ......................................................................
66 % ......................................................................
67 % ......................................................................
69 % ......................................................................
71 % ......................................................................
72 % ......................................................................
74 % ......................................................................
75 % ......................................................................
77 % ......................................................................
78 % ......................................................................
80 % ......................................................................
82 % ......................................................................
83 % ......................................................................
85 % ......................................................................
86 % ......................................................................
88 % ......................................................................
89 % ......................................................................
91 % ......................................................................
93 % ......................................................................
94 % ......................................................................
96 % ......................................................................
97 % ......................................................................
99 %
Done
Finishing transfer
Type Ctrl-\ + c to quit
U-Boot 2024.07 (Sep 18 2024 - 04:41:30 +0900)
SoC: MV88F6820-A0 at 1600 MHz
I2C: ready
DRAM: 2 GiB (800 MHz, 32-bit, ECC not enabled)
Core: 30 devices, 19 uclasses, devicetree: separate
MMC: mv_sdh: 0
Loading Environment from SPIFlash... Invalid bus 0 (err=-19)
*** Warning - spi_flash_probe_bus_cs() failed, using default environment
Model: Marvell Armada 385 GP
Board: Marvell DB-88F6820-GP
Net:
Error: ethernet@70000 No valid MAC address found.
Error: ethernet@30000 No valid MAC address found.
No ethernet found.
=>
U-BootをUARTブートして, OpenWrt のinitramfsを起動する
イーサネットデバイスを使えるようにする方法がわからなかったので、minicomからxmodemでinitramfsを転送してブートしてみることにした
FortiGate 50EのinitramfsはストックファームウェアのU-Bootのチェックを通すためにいろいろヘッダが追加されているので、OpenWRT公式のビルド済みファームウェアがそのままブートできるわけではない
ビルド時に、U-Bootでブート可能なzImageとdtbがbuild_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/linux-mvebu_cortexa9にできるのでこれを使用する
使用するのは以下のファイル
zImage-initramfs
image-armada-385-fortinet-fg-50e.dtb
手順
以下のオプションを有効にしてU-Bootをビルドする
Command line interface
Boot commands
bootz
OpenWRTをビルドする
xmodemの転送に時間がかかるので、はずせるものはとにかくはずしてイメージの容量を小さくする
code:sh
make menuconfig
あんまり小さくならなかったのでデフォルトより小さくしようとするのは無駄な努力かも
ビルドする
code:sh
time make -j$(nproc) defconfig download clean world
UARTブートでU-Bootを起動する
code:sh
sudo kwboot -b ~/src/u-boot/u-boot-with-spl.kwb -t -B 115200 /dev/ttyUSB0
U-Bootの起動が完了したら、Ctrl-\ C と入力してkwbootのコンソールから抜ける
minicomからシリアルコンソールに接続する
code:sh
sudo minicom -D /dev/ttyUSB0 -b 115200
起動したらminicomメニューの 設定 -> シリアルポート からハードウェアフロー制御をoffにする
zImage-initramfs をロードする
code:u-boot
loadx 0x800000
上記のコマンドを実行したらminicomからzImage-initramfsを送信する
xmodemで転送するには容量がでかいので結構時間がかかる
image-armada-385-fortinet-fg-50e.dtb をロードする
code:u-boot
loadx 0x8300000
上記のコマンドを実行したらminicomからimage-armada-385-fortinet-fg-50e.dtbを送信する
カーネルをブートする
code:u-boot
bootz 0x800000 - 0x8300000
Starting kernel ... と出てきたら起動成功
OpenWRTのシリアルコンソールは9600bpsしか対応していないので、これ以降なにも出なくなる
minicomをいちど終了して、9600bpsで再度接続する
code:sh
sudo minicom -D /dev/ttyUSB0 -b 9600
initramfsでもEthernetが使えてない
U-BootにOpenWrtのdtsをひっぱってきてビルドしたときはinitramfsでEthernetが使えてたので、もういちどその状態にしてみる
参考
https://chatgpt.com/share/66ea4971-91ec-8010-8454-9efd9827504a